﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="GioHang.aspx.cs" Inherits="GUI.GioHang" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="title_content">
        Giỏ hàng
    </div>
    <div class="border_content">
        <div style="text-align: center;">
            <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                <ProgressTemplate>
                    <img src="Home/css/images/loading.gif" alt="Loading" />
                    Đang xử lý ...
                </ProgressTemplate>
            </asp:UpdateProgress>
        </div>
        <%-- <div class="clear" style="color: #CC3300">
            <div id="progress">
                <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                    <ProgressTemplate>
                        <img src="Home/images/progress.gif" width="24px" height="24px" alt='' />
                    </ProgressTemplate>
                </asp:UpdateProgress>
            </div>
        </div>--%>
        <!-- slide -->
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <center>
                    <%-- <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                        <ProgressTemplate>
                            <img src="Images/loading.gif" alt="" title="Đang xử lý" />
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                    <br />--%>
                    <%
                        if (this.gioHang != null)
                        {
                            if (this.gioHang.Count > 0)
                            {
                    %>
                    <b>Lưu ý:</b>&nbsp; <font color="red">Quý khách chỉ có thể mua tối đa số lượng 100 cho
                        mỗi sản phẩm! </font>
                    <%       
                            }
                        }
                    %>
                    <br />
                    <br />
                </center>
                <asp:GridView ID="GVGioHang" runat="server" BackColor="White" CellPadding="4" ShowFooter="True"
                    AutoGenerateColumns="False" Width="100%" OnRowDataBound="GVGioHang_RowDataBound"
                    OnRowCommand="GVGioHang_RowCommand">
                    <Columns>
                        <asp:TemplateField HeaderText="Mã Sản Phẩm" Visible="false">
                            <ItemTemplate>
                                <asp:Label ID="lblmasanpham" runat="server" Text='<%# Eval("MaSanPham") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Xóa">
                            <ItemTemplate>
                                <asp:LinkButton ID="btnXoa" CommandArgument='<%#Eval("MaSanPham") %>' CommandName='xoa'
                                    runat="server">
                                    <img src="Home/images/delete_icon.gif" alt="Xóa" />
                                </asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Tên Sản Phẩm">
                            <ItemTemplate>
                                <a href="ChiTietSanPham.aspx?MaSanPham=<%# Eval("MaSanPham") %>" target="_blank"
                                    style="color: rgb(217, 0, 93); text-decoration: none;">
                                    <%# Eval("TenSanPham") %></a>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Số Lượng">
                            <FooterTemplate>
                            </FooterTemplate>
                            <ItemTemplate>
                                <asp:TextBox ID="txtsoluong" runat="server" Height="18px" Text='<%# Eval("SoLuong") %>'
                                    Width="47px" ValidationGroup="soluong"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredSoLuong" runat="server" ErrorMessage="*"
                                    ControlToValidate="txtsoluong" Display="Dynamic" ValidationGroup="soluong" ForeColor="Red"></asp:RequiredFieldValidator>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Đơn Giá">
                            <FooterTemplate>
                                <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Tổng Tiền: "></asp:Label>
                                &nbsp;
                            </FooterTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblgiaban" runat="server" Text='<%# Eval("GiaBan", "{0:0,0 VNĐ}") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Thành Tiền">
                            <FooterTemplate>
                                <asp:Label ID="lbltongtien" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="#CC3300"
                                    Text='<%# LoadTongTien(null) %>'></asp:Label>
                            </FooterTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblthanhtien" runat="server" Text='<%# LoadThanhTien(Eval("GiaBan"),Eval("SoLuong")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <p style="text-align: center;">
                            <span style="font-size: medium; color: rgb(200,0,0);"><strong>Không có sản phẩm nào
                                trong giỏ hàng</strong></span></p>
                        <br />
                        <p style="text-align: center;">
                            <asp:HyperLink ID="hplquayvetrangchu" runat="server" ForeColor="#3399FF" NavigateUrl="~/Default.aspx">Quay về trang chủ</asp:HyperLink>
                        </p>
                    </EmptyDataTemplate>
                    <FooterStyle BackColor="#D8C0E6" ForeColor="#330099" HorizontalAlign="Center" />
                    <HeaderStyle BackColor="#0066FF" Font-Bold="True" ForeColor="#FFFFFF" />
                    <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                    <RowStyle BackColor="White" ForeColor="Black" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                </asp:GridView>
                <div class="clear">
                </div>
                <br />
                <div class="thongtin">
                    <table width="100%" border="0">
                        <tr>
                            <td style="width: 262px">
                                <asp:Button ID="btnTiepTucMuaHang" runat="server" Text="Tiếp tục mua hàng" OnClick="btnTiepTucMuaHang_Click" />
                            </td>
                            <td style="width: 230px">
                                <asp:Button ID="btnCapNhat" runat="server" Text="Cập Nhật" OnClick="btnCapNhat_Click" />
                            </td>
                            <td style="width: 218px">
                                <asp:Button ID="btnXoaGioHang" OnClientClick="return confirm('Bạn có muốn hủy giỏ hàng thật không?');"
                                    runat="server" Text="Hủy giỏ hàng" OnClick="btnXoaGioHang_Click" />
                            </td>
                            <td>
                                <asp:Button ID="btnMuaHang" runat="server" Text="Thanh toán" OnClick="btnMuaHang_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 262px">
                                &nbsp;
                            </td>
                            <td style="width: 230px">
                                &nbsp;
                            </td>
                            <td style="width: 218px">
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" style="text-align: center;">
                                <asp:Label ID="LabelThongBaoDangNhap" ForeColor="Red" Visible="false" runat="server"
                                    Text="(*) Bạn chưa đăng nhập, xin hãy đăng nhập trước khi mua hàng !">
                                </asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 262px">
                                &nbsp;
                            </td>
                            <td style="width: 230px">
                                &nbsp;
                            </td>
                            <td style="width: 218px">
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
